<template>
  <div>
    <div align="center">
      <label size="large" label-width="280px">— — — — — — — — — — — — —</label><br/>
      <label size="large" label-width="280px">* * * 燃气管道泄漏爆炸危害模型 * * *</label><br/>
      <label size="large" label-width="280px">— — — — — — — — — — — — —</label>
    </div>
    <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="200px">
      <el-form-item label="体积形状" prop="shape">
        <el-select v-model="formData.shape" placeholder="请选择体积形状" clearable :style="{width: '80%'}">
          <el-option v-for="(item, index) in shapeOptions" :key="index" :label="item.label"
                     :value="item.value" :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="长方体的高（单位：米）" prop="high">
        <el-input-number step="0.01" v-model="formData.high" placeholder="请输入长方体的高（单位：米）" clearable :style="{width: '80%'}">
        </el-input-number>
      </el-form-item>
      <el-form-item label="长方体的宽（单位：米）" prop="wide">
        <el-input-number step="0.01"  v-model="formData.wide" placeholder="请输入长方体的宽（单位：米）" clearable :style="{width: '80%'}">
        </el-input-number>
      </el-form-item>
      <el-form-item label="长度（单位：米）" prop="length">
        <el-input-number step="0.01"  v-model="formData.length" placeholder="请输入长度（单位：米）" clearable :style="{width: '80%'}">
        </el-input-number>
      </el-form-item>
      <el-form-item label="圆柱体半径（单位：米）" prop="r">
        <el-input-number v-model="formData.r" placeholder="请输入圆柱体半径（单位：米）" clearable :style="{width: '80%'}">
        </el-input-number>
      </el-form-item>
      <el-form-item label="不规则形状体积" prop="v">
        <el-input-number step="0.001"  v-model="formData.v" placeholder="请输入直接体积,（单位m^3）" clearable :style="{width: '80%'}">
        </el-input-number>
      </el-form-item>
      <el-form-item size="large">
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
    <el-dialog
      title="评估结果"
      :visible.sync="centerDialogVisible"
      width="30%"
      center>
      <span>死亡半径:{{R1}}（米）;重伤半径:{{R2}}（米）;轻伤半径:{{R3}}（米）;破坏半径建筑物:{{R4}}（米）;爆炸产生的TNT当量:{{WTNT}};</span>
      <span slot="footer" class="dialog-footer">
    <el-button @click="centerDialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>
<script>
  import {handleRQGD14} from "../../../api/edu/risk";

  export default {
    components: {},
    props: [],
    data() {
      return {
        centerDialogVisible : false,
        formData: {
          shape: undefined,
          high: undefined,
          wide: undefined,
          length: undefined,
          r: undefined,
          v: undefined,
        },
        rules: {
          shape: [{
            required: true,
            message: '请选择体积形状',
            trigger: 'change'
          }],
          high: [],
          wide: [],
          length: [],
          r: [],
          v: [],
        },
        shapeOptions: [{
          "label": "长方体",
          "value": 1
        }, {
          "label": "圆柱体",
          "value": 2
        }, {
          "label": "不规则体",
          "value": ""
        }],
      }
    },
    computed: {},
    watch: {},
    created() {},
    mounted() {},
    methods: {
      submitForm() {
        handleRQGD14(this.formData).then(response => {
          console.log(response)
           this.R1 = response.R1;
          this.R2 = response.R2;
          this.R3 = response.R3;
          this.R4 = response.R4;
          this.WTNT = response.WTNT;
            this.centerDialogVisible = true
        }).catch((error) => {
          console.log(error);
        });
      },
      resetForm() {
        this.$refs['elForm'].resetFields()
      },
    }
  }

</script>
<style>
</style>
